<extend name="Common@Common/base"/>
<block name="style">
    <link rel="stylesheet" type="text/css" href="__MEMBER__/css/modify-password.css">
</block>


<block name="data">
    <div class="tw-tabs">
        <ul class="tw-tabs-nav title-tabs">
            <li class="tw-nav-item title-tab title-tab-current">
                <a href="javascript: void(0)">登录密码修改</a>
            </li>
            <li class="tw-nav-item title-tab">
                <a href="javascript: void(0)">验证密码修改</a>
            </li>
        </ul>

        <!-- 内容区块一 -->
        <div class="tw-tabs-bd">
            <div class="tw-tab-panel">

                    <table>
                        <tr>
                            <col width="100px">
                            <col width="">
                        </tr>
                        <tr>
                            <td class="key">原密码：</td>
                            <td><input class="input_text" autocomplete="off" type="password" placeholder="请输入原登录密码" id="login_password"
                                       name="login_password"></td>
                        </tr>
                        <tr>
                            <td class="key">新密码：</td>
                            <td><input class="input_text" autocomplete="off" type="password" placeholder="请输入至少4位新登录密码" name="new_login_password" id="new_login_password"></td>
                        </tr>
                        <tr>
                            <td class="key">确认密码：</td>
                            <td><input class="input_text" autocomplete="off" type="password" placeholder="请再次输入至少4位新登录密码"name="re_new_login_password" id="re_new_login_password"></td>
                        </tr>
                    </table>

                    <div>
                        <button type="button" id="loginpsd" class="button btn"><p>提&nbsp;&nbsp; &nbsp;交</p></button>
                    </div>
            </div>
        </div>

        <!-- 内容区块二 -->
        <div class="tw-tab-panel">
            <div class="tw-panel-cnt">

                <table>
                    <tr>
                        <col width="100px">
                        <col width="">
                    </tr>
                    <tr>
                        <td class="key">原密码：</td>
                        <td><input class="input_text" type="password" placeholder="请输入原验证密码" name="pay_password" id="pay_password"></td>
                    </tr>
                    <tr>
                        <td class="key">新密码：</td>
                        <td><input class="input_text" type="password" placeholder="请输入6位纯数字新验证密码" name="new_pay_password" id="new_pay_password">
                        </td>
                    </tr>
                    <tr>
                        <td class="key">确认密码：</td>
                        <td><input class="input_text" type="password" placeholder="请再次输入6位纯数字新验证密码" id="pre_new_pay_password"
                                   name="pre_new_pay_password"></td>
                    </tr>
                </table>

                <div>
                    <button type="button" id="paypsd" class="button btn">提 &nbsp; &nbsp;交</button>
                </div>

            </div>
        </div>
    </div>


</block>

<block name="script">
    <script type="text/javascript" src="__PUBLIC__/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/assets/js/common.js"></script>
    <script type="text/javascript" src="__PUBLIC__/assets/js/hex_sha1.js"></script>
    <script type="text/javascript" src="__PUBLIC__/toastr/toastr.js"></script>
    <script type="text/javascript" src="__COMMON__/js/tabs.js"></script>
    <script type="text/javascript">

        // 这是修改登录密码操作
        $('#loginpsd').click(function () {

            var login_password = $('input[name="login_password"]');

            var new_login_password =$('input[name="new_login_password"]');

            var re_new_login_password =$('input[name="re_new_login_password"]');

            // 原密码只要不为空，就对他进行加密
            if($.trim(login_password.val())==''){
                toastr.error('原密码不能为空');
                login_password.focus();
                return false;
            }

            if(new_login_password.val().length<4 || new_login_password.val().length>20){
                toastr.error('新密码长度4-20位');
                new_login_password.focus();
                return false;
            }else{
                if(new_login_password.val()!==re_new_login_password.val()){
                    toastr.error('两次输入的新密码不一致！');
                    new_login_password.focus();
                    return false;
                }else{
                    login_password.val($.trim(hex_sha1(login_password.val())));

                    new_login_password.val($.trim(hex_sha1(new_login_password.val())));
                    re_new_login_password.val( $.trim(hex_sha1(new_login_password.val())));


                    $.ajax({
                        type:'POST',
                        url:"__URL__/doModifyLoginPassword",
                        data:{
                            login_password:$('input[name="login_password"]').val(),
                            new_login_password:$('input[name="new_login_password"]').val(),
                        },

                        success:function(data){
                            if(data['status']==0){
                                toastr.error(data['info']);
                            }
                            if(data['status']==1){
                                toastr.success(data['info']);
                            }
                            $('#login_password').val('');
                            $('#new_login_password').val('');
                            $('#re_new_login_password').val('');
                            $('#pay_password').val('');
                            $('#new_pay_password').val('');
                            $('#pre_new_pay_password').val('');
                        }
                    })
                }
            }
        });


        //这里是修改验证密码的地方

        $('#paypsd').click(function () {

            var pay_password = $('input[name="pay_password"]');

            var new_pay_password =$('input[name="new_pay_password"]');

            var pre_new_pay_password =$('input[name="pre_new_pay_password"]');

            // 原密码只要不为空，就对他进行加密
            if($.trim(pay_password.val())==''){
                toastr.error('原密码不能为空');
                pay_password.focus();
                return false;
            }

            if(new_pay_password.val().length==6 && /^\d+$/.test(new_pay_password.val()) == true){

                if(new_pay_password.val()!==pre_new_pay_password.val()){
                    toastr.error('两次输入的新密码不一致！');
                    new_pay_password.focus();
                    return false;
                }else{
                    pay_password.val($.trim(hex_sha1(pay_password.val())));

                    new_pay_password.val($.trim(hex_sha1(new_pay_password.val())));
                    pre_new_pay_password.val( $.trim(hex_sha1(new_pay_password.val())));

                    $.ajax({
                        type:'POST',
                        url:"__URL__/doModifyPayPassword",
                        data:{
                            pay_password:$('input[name="pay_password"]').val(),
                            new_pay_password:$('input[name="new_pay_password"]').val(),
                        },
                        success:function(data){
                            if(data['status']==0){
                                toastr.error(data['info']);
                            }
                            if(data['status']==1){
                                toastr.success(data['info']);
                            }
                            $('#login_password').val('');
                            $('#new_login_password').val('');
                            $('#re_new_login_password').val('');
                            $('#pay_password').val('');
                            $('#new_pay_password').val('');
                            $('#pre_new_pay_password').val('');
                        }
                    })
                }
            }else{
                toastr.error('新验证密码必须是6位纯数字');
                new_pay_password.focus();
                return false;
            }
        });


    </script>
</block>